package com.hfzy.ihk.web.aliyuncall.biz;

import com.hfzy.ihk.common.util.string.StringTools;
import com.hfzy.ihk.web.aliyuncall.context.DisruptorInitBean;
import com.hfzy.ihk.web.aliyuncall.support.disruptor.DisruptorSupport;
import com.hfzy.ihk.web.aliyuncall.support.disruptor.base.DisruptorEvent;
import com.hfzy.ihk.web.aliyuncall.vo.AliyunCallState;
import com.hfzy.ihk.web.aliyuncall.vo.AliyunRecordFile;
import com.lmax.disruptor.RingBuffer;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 阿里云接收录音文件业务处理类 可以在此进入队列
 */
@Lazy
@Component("aliyunRecordFileBiz")
public class AliyunRecordFileBiz extends DisruptorSupport<AliyunRecordFile,DisruptorEvent<AliyunRecordFile>> {


    @Override
    protected RingBuffer<DisruptorEvent<AliyunRecordFile>> useRingBuffer(AliyunRecordFile data) {
        RingBuffer ringBuffer = null;
        String useType = "阿里云录音文件";
        ringBuffer = DisruptorInitBean.getRingBufferAliyunRecordFile();
        checkRingBufferUse(ringBuffer,useType);
        return ringBuffer;
    }

    /**
     * 处理状态消息
     * @param
     */

    public void dealCallState(List<AliyunRecordFile> aliyunRecordFiles){

        if(StringTools.isEmpty(aliyunRecordFiles)){
            return;
        }

        for(AliyunRecordFile aliyunRecordFile:aliyunRecordFiles){
            putInRingBuffer(aliyunRecordFile);
        }

    }

}
